<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" id='YZMipt'>
    <span id="YZM"></span>
    <button id="checkBtn">提交</button>
    <script>
        var YZM = document.getElementById('YZM');
        var YZMipt = document.getElementById('YZMipt');
        var checkBtn = document.getElementById('checkBtn');

        function yzmFn() {
            var yzmStr = '012345678qwertyuiopasdfghjklzxcvbnmWERTYUIOPLKJHGFDSAZXCVBNM';
            var yzmout = '';
            for (var i = 0; i < 4; i++) {
                var yzm1 = yzmStr[Math.floor(Math.random() * yzmStr.length)];
                yzmout += yzm1;
            }
            YZM.innerText = yzmout;
        }
        yzmFn();
        checkBtn.onclick = function() {
            console.log(YZMipt.value.toLowerCase)
            if (YZMipt.value.toLowerCase == YZM.innerText.toLowerCase) {
                alert('验证成功');
            } else {
                alert('验证失败');
            }
        }
    </script>
</body>

</html>